package com.example.videoplayer.controller;

import com.example.videoplayer.model.User;
import com.example.videoplayer.model.Video;
import com.example.videoplayer.model.Category;
import com.example.videoplayer.repository.UserRepository;
import com.example.videoplayer.repository.VideoRepository;
import com.example.videoplayer.repository.CategoryRepository;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/api/admin")
public class AdminController {

    private final UserRepository userRepository;
    private final VideoRepository videoRepository;
    private final CategoryRepository categoryRepository;

    public AdminController(UserRepository userRepository, 
                         VideoRepository videoRepository,
                         CategoryRepository categoryRepository) {
        this.userRepository = userRepository;
        this.videoRepository = videoRepository;
        this.categoryRepository = categoryRepository;
    }

    @GetMapping("/users")
    public Flux<User> getAllUsers() {
        return userRepository.findAll();
    }

    @GetMapping("/videos")
    public Flux<Video> getAllVideos() {
        return videoRepository.findAll();
    }

    @GetMapping("/categories")
    public Flux<Category> getAllCategories() {
        return categoryRepository.findAll();
    }
} 